<template>
    <div>
        <van-nav-bar title="商品分类" />
        <van-skeleton title :row="3" v-show="gjp"/>
        <div>
            <van-pull-refresh v-model="loading" @refresh="onRefresh">
                <van-row>
                    <van-col span="6">
                        <van-sidebar v-model="active">
                            <van-sidebar-item v-for="item in categories" :title="item.cat_name" />

                        </van-sidebar>

                    
                    
                    </van-col>
                 
                    <van-col span="18">
                      
                        <div v-for="item in categories[active]?.children">
                              <div><van-search v-model="value" placeholder="请输入搜索关键词" /></div>
                            <h4>{{ item.cat_name }}</h4>
                                 <router-link :to="{name:'search',params:{query:item.cat_name}}">
                                    <van-grid :column-num="4">
                                    <van-grid-item v-for="items in item.children" :icon="items.cat_icon"
                                    :text="items.cat_name" />
                                    </van-grid>

                                 </router-link> 
                                
                                   
                            


                           
                            
                        </div>
                        <!-- <van-pagination v-model="currentPage" :page-count="4" mode="simple" /> -->


                    </van-col>
                </van-row>

            </van-pull-refresh>


        </div>

    </div>
    <van-submit-bar :price="3050" button-text="提交订单" @submit="onSubmit" />
</template>

<script setup>
import { ref, watch } from 'vue';
import { categoriesApi } from '@/api/api';
import { showToast } from 'vant';
import _ from 'lodash'
let categories = ref([])
categoriesApi().then(res => {
    console.log('分类', res)
    categories.value = res.data.message
})
let active = ref(0)
  const loading = ref(false);
    const onRefresh = () => {
      setTimeout(() => {
        showToast('刷新成功');
        loading.value = false;
      
      }, 1000);
    };
let gjp=ref(true)
setInterval(()=>{
    gjp.value=false
},1000)



</script>

<style lang="scss" scoped></style>